﻿using GalaSoft.MvvmLight.Messaging;
using System;
using System.Windows;

namespace RandomMobileNumber.Views
{
    /// <summary>
    /// SoldWindow.xaml 的交互逻辑
    /// </summary>
    public partial class SoldWindow : Window
    {
        public SoldWindow()
        {
            InitializeComponent();
            Loaded += SoldWindow_Loaded;
            Closed += SoldWindow_Closed;
        }

        private void SoldWindow_Closed(object sender, EventArgs e)
        {
            Messenger.Default.Unregister<NotificationMessage>(this);
        }

        private void SoldWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Messenger.Default.Register<NotificationMessage>(this, m =>
            {
                if (m.Notification.Equals("close"))
                {
                    this.DialogResult = true;
                    this.Close();
                }
            });
        }
    }
}
